using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;

namespace Server.Gumps
{
    public class PetLevelGump : Gump
    {
        /*
         * + and - to use 0x37, 0x38
         * the +5 icon 0x8B5
         * Okay 0x2EEE, 0x2EED
         * Clear 0x2EE3, 0x2EE4
         * 
         * 
         */
        private Mobile m_Pet;
        private int usedAbilityPointsThisSesion = 0;

        public PetLevelGump(Mobile pet)
            : base(0, 0)
        {
            CreateGump(pet);
        }
        public PetLevelGump(Mobile pet, int recentlyUsedPoints)
            : base(0, 0)
        {
            usedAbilityPointsThisSesion = recentlyUsedPoints;
            CreateGump(pet);
        }
        private void CreateGump(Mobile pet)
        {
            m_Pet = pet;

            BaseCreature bc = (BaseCreature)m_Pet;

            Closable = true;
            Disposable = true;
            Dragable = true;
            Resizable = false;

            AddPage(0);

            AddBackground(12, 9, 394, 556, 0x13BE);
            AddImageTiled(17, 136, 302, 27, 9274);
            AddImageTiled(17, 171, 302, 356, 9274);
            AddImageTiled(326, 136, 76, 27, 9274);
            AddImageTiled(326, 171, 76, 354, 9274);
            AddLabel(22, 20, 1149, @"Ability Points:");
            AddLabel(22, 40, 1149, @"Pets Current Level:");
            AddLabel(22, 60, 1149, @"Pets Maxium Level:");
            AddLabel(22, 80, 1149, @"Pets Gender:");
            AddLabel(22, 100, 1149, @"Pets Name:");

            AddLabel(116, 20, 64, bc.AbilityPoints.ToString());
            AddLabel(149, 40, 64, bc.Level.ToString());
            AddLabel(144, 60, 64, bc.MaxLevel.ToString());

            //AddImage(336, 20, 5549);
            AddImage(336, 20, 0x408);

            AddButton(300, 100, 2117, 2118, 1, GumpButtonType.Page, 1);
            AddButton(320, 100, 2117, 2118, 1, GumpButtonType.Page, 2);

            if (bc.Female == true)
                AddLabel(107, 80, 64, @"Female");
            else
                AddLabel(107, 80, 64, @"Male");
            AddLabel(96, 100, 64, bc.Name.ToString());

            AddLabel(22, 140, 1149, @"Property Name");
            AddLabel(330, 140, 1149, @"Amount");

            AddPage(1);

            if (bc.Level != 0)
            {
                /* Old Way
                AddLabel(60, 175, 1149, @"Hit Points");
                AddLabel(60, 200, 1149, @"Stamina");
                AddLabel(60, 225, 1149, @"Mana");*/

                AddLabel(24, 175, 1149, @"Hit Points");
                AddLabel(24, 200, 1149, @"Stamina");
                AddLabel(24, 225, 1149, @"Mana");

                AddLabel(330, 175, 1149, bc.HitsMax.ToString() + "/" + FSATS.NormalHITS.ToString());
                AddLabel(330, 200, 1149, bc.StamMax.ToString() + "/" + FSATS.NormalSTAM.ToString());
                AddLabel(330, 225, 1149, bc.ManaMax.ToString() + "/" + FSATS.NormalMANA.ToString());

                /* Old Way
                AddButton(24, 175, 4005, 4006, 1, GumpButtonType.Reply, 0);
                AddButton(24, 200, 4005, 4006, 2, GumpButtonType.Reply, 0);
                AddButton(24, 225, 4005, 4006, 3, GumpButtonType.Reply, 0);*/

                // Max Buttons ?
                AddButton(260, 175, 0x827, 0x827, 1, GumpButtonType.Reply, 0);
                AddButton(260, 200, 0x827, 0x827, 2, GumpButtonType.Reply, 0);
                AddButton(260, 225, 0x827, 0x827, 3, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 175, 1149, @"Max");
                AddLabel(280, 200, 1149, @"Max");
                AddLabel(280, 225, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 175, 0x37, 0x38, 4, GumpButtonType.Reply, 0);
                AddButton(240, 200, 0x37, 0x38, 5, GumpButtonType.Reply, 0);
                AddButton(240, 225, 0x37, 0x38, 6, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 175, 0x38, 0x37, 7, GumpButtonType.Reply, 0);
                AddButton(220, 200, 0x38, 0x37, 8, GumpButtonType.Reply, 0);
                AddButton(220, 225, 0x38, 0x37, 9, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 175, 38, @"-Locked-");
                AddLabel(60, 200, 38, @"-Locked-");
                AddLabel(60, 225, 38, @"-Locked-");

                AddLabel(330, 175, 38, @"???");
                AddLabel(330, 200, 38, @"???");
                AddLabel(330, 225, 38, @"???");
            }

            if (bc.Level >= 10)
            {
                AddLabel(24, 250, 1149, @"Physical Resistance");
                AddLabel(24, 275, 1149, @"Fire Resistance");
                AddLabel(24, 300, 1149, @"Cold Resistance");
                AddLabel(24, 325, 1149, @"Energy Resistance");
                AddLabel(24, 350, 1149, @"Poison Resistance");

                AddLabel(330, 250, 1149, bc.PhysicalResistance.ToString() + "/" + FSATS.NormalPhys.ToString());
                AddLabel(330, 275, 1149, bc.FireResistance.ToString() + "/" + FSATS.NormalFire.ToString());
                AddLabel(330, 300, 1149, bc.ColdResistance.ToString() + "/" + FSATS.NormalCold.ToString());
                AddLabel(330, 325, 1149, bc.EnergyResistance.ToString() + "/" + FSATS.NormalEnergy.ToString());
                AddLabel(330, 350, 1149, bc.PoisonResistance.ToString() + "/" + FSATS.NormalPoison.ToString());

                /* Old Way
                AddButton(24, 250, 4005, 4006, 4, GumpButtonType.Reply, 0);
                AddButton(24, 275, 4005, 4006, 5, GumpButtonType.Reply, 0);
                AddButton(24, 300, 4005, 4006, 6, GumpButtonType.Reply, 0);
                AddButton(24, 325, 4005, 4006, 7, GumpButtonType.Reply, 0);
                AddButton(24, 350, 4005, 4006, 8, GumpButtonType.Reply, 0);
                 */
                // Max Buttons ?
                AddButton(260, 250, 0x827, 0x827, 10, GumpButtonType.Reply, 0);
                AddButton(260, 275, 0x827, 0x827, 11, GumpButtonType.Reply, 0);
                AddButton(260, 300, 0x827, 0x827, 12, GumpButtonType.Reply, 0);
                AddButton(260, 325, 0x827, 0x827, 13, GumpButtonType.Reply, 0);
                AddButton(260, 350, 0x827, 0x827, 14, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 250, 1149, @"Max");
                AddLabel(280, 275, 1149, @"Max");
                AddLabel(280, 300, 1149, @"Max");
                AddLabel(280, 325, 1149, @"Max");
                AddLabel(280, 350, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 250, 0x37, 0x38, 15, GumpButtonType.Reply, 0);
                AddButton(240, 275, 0x37, 0x38, 16, GumpButtonType.Reply, 0);
                AddButton(240, 300, 0x37, 0x38, 17, GumpButtonType.Reply, 0);
                AddButton(240, 325, 0x37, 0x38, 18, GumpButtonType.Reply, 0);
                AddButton(240, 350, 0x37, 0x38, 19, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 250, 0x38, 0x37, 20, GumpButtonType.Reply, 0);
                AddButton(220, 275, 0x38, 0x37, 21, GumpButtonType.Reply, 0);
                AddButton(220, 300, 0x38, 0x37, 22, GumpButtonType.Reply, 0);
                AddButton(220, 325, 0x38, 0x37, 23, GumpButtonType.Reply, 0);
                AddButton(220, 350, 0x38, 0x37, 24, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 250, 38, @"-Locked-");
                AddLabel(60, 275, 38, @"-Locked-");
                AddLabel(60, 300, 38, @"-Locked-");
                AddLabel(60, 325, 38, @"-Locked-");
                AddLabel(60, 350, 38, @"-Locked-");

                AddLabel(330, 250, 38, @"???");
                AddLabel(330, 275, 38, @"???");
                AddLabel(330, 300, 38, @"???");
                AddLabel(330, 325, 38, @"???");
                AddLabel(330, 350, 38, @"???");
            }

            if (bc.Level >= 20)
            {
                AddLabel(24, 375, 1149, @"Min Damage");
                AddLabel(24, 400, 1149, @"Max Damage");

                AddLabel(330, 375, 1149, bc.DamageMin.ToString() + "/" + FSATS.NormalMinDam.ToString());
                AddLabel(330, 400, 1149, bc.DamageMax.ToString() + "/" + FSATS.NormalMaxDam.ToString());

                /* Old Way
                AddButton(24, 375, 4005, 4006, 9, GumpButtonType.Reply, 0);
                AddButton(24, 400, 4005, 4006, 10, GumpButtonType.Reply, 0);*/
                // Max Buttons ?
                AddButton(260, 375, 0x827, 0x827, 25, GumpButtonType.Reply, 0);
                AddButton(260, 400, 0x827, 0x827, 26, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 375, 1149, @"Max");
                AddLabel(280, 400, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 375, 0x37, 0x38, 27, GumpButtonType.Reply, 0);
                AddButton(240, 400, 0x37, 0x38, 28, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 375, 0x38, 0x37, 29, GumpButtonType.Reply, 0);
                AddButton(220, 400, 0x38, 0x37, 30, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 375, 38, @"-Locked-");
                AddLabel(60, 400, 38, @"-Locked-");

                AddLabel(330, 375, 38, @"???");
                AddLabel(330, 400, 38, @"???");
            }

            if (bc.Level >= 30)
            {
                AddLabel(24, 425, 1149, @"Armor Rating");

                AddLabel(330, 425, 1149, bc.VirtualArmor.ToString() + "/" + FSATS.NormalVArmor.ToString());

                // Old Way AddButton(24, 425, 4005, 4006, 11, GumpButtonType.Reply, 0);
                // Max Buttons ?
                AddButton(260, 425, 0x827, 0x827, 31, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 425, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 425, 0x37, 0x38, 32, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 425, 0x38, 0x37, 33, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 425, 38, @"-Locked-");

                AddLabel(330, 425, 38, @"???");
            }

            if (bc.Level >= 40)
            {
                AddLabel(24, 450, 1149, @"Strength");
                AddLabel(24, 475, 1149, @"Dexterity");
                AddLabel(24, 500, 1149, @"Intelligence");

                AddLabel(330, 450, 1149, bc.RawStr.ToString() + "/" + FSATS.NormalSTR.ToString());
                AddLabel(330, 475, 1149, bc.RawDex.ToString() + "/" + FSATS.NormalDEX.ToString());
                AddLabel(330, 500, 1149, bc.RawInt.ToString() + "/" + FSATS.NormalINT.ToString());

                /* Old Way
                AddButton(24, 450, 4005, 4006, 12, GumpButtonType.Reply, 0);
                AddButton(24, 475, 4005, 4006, 13, GumpButtonType.Reply, 0);
                AddButton(24, 500, 4005, 4006, 14, GumpButtonType.Reply, 0);*/
                // Max Buttons ?
                AddButton(260, 450, 0x827, 0x827, 34, GumpButtonType.Reply, 0);
                AddButton(260, 475, 0x827, 0x827, 35, GumpButtonType.Reply, 0);
                AddButton(260, 500, 0x827, 0x827, 36, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 450, 1149, @"Max");
                AddLabel(280, 475, 1149, @"Max");
                AddLabel(280, 500, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 450, 0x37, 0x38, 37, GumpButtonType.Reply, 0);
                AddButton(240, 475, 0x37, 0x38, 38, GumpButtonType.Reply, 0);
                AddButton(240, 500, 0x37, 0x38, 39, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 450, 0x38, 0x37, 40, GumpButtonType.Reply, 0);
                AddButton(220, 475, 0x38, 0x37, 41, GumpButtonType.Reply, 0);
                AddButton(220, 500, 0x38, 0x37, 42, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 450, 38, @"-Locked-");
                AddLabel(60, 475, 38, @"-Locked-");
                AddLabel(60, 500, 38, @"-Locked-");

                AddLabel(330, 450, 38, @"???");
                AddLabel(330, 475, 38, @"???");
                AddLabel(330, 500, 38, @"???");
            }

            AddPage(2);

            if (bc.Level > 25)
            {
                AddLabel(24, 175, 1149, @"Roar Attack");
                AddLabel(24, 200, 1149, @"Poison Attack");
                AddLabel(24, 225, 1149, @"Fire Breath Attack");

                AddLabel(330, 175, 1149, bc.RoarAttack.ToString() + "/" + "100");
                AddLabel(330, 200, 1149, bc.PetPoisonAttack.ToString() + "/" + "100");
                AddLabel(330, 225, 1149, bc.FireBreathAttack.ToString() + "/" + "100");

                /* Old Way 
                AddButton(24, 175, 4005, 4006, 15, GumpButtonType.Reply, 0);
                AddButton(24, 200, 4005, 4006, 16, GumpButtonType.Reply, 0);
                AddButton(24, 225, 4005, 4006, 17, GumpButtonType.Reply, 0);*/
                // Max Buttons ?
                AddButton(260, 175, 0x827, 0x827, 43, GumpButtonType.Reply, 0);
                AddButton(260, 200, 0x827, 0x827, 44, GumpButtonType.Reply, 0);
                AddButton(260, 225, 0x827, 0x827, 45, GumpButtonType.Reply, 0);

                // Max Buttons Text
                AddLabel(280, 175, 1149, @"Max");
                AddLabel(280, 200, 1149, @"Max");
                AddLabel(280, 225, 1149, @"Max");

                // Plus Buttons
                AddButton(240, 175, 0x37, 0x38, 46, GumpButtonType.Reply, 0);
                AddButton(240, 200, 0x37, 0x38, 47, GumpButtonType.Reply, 0);
                AddButton(240, 225, 0x37, 0x38, 48, GumpButtonType.Reply, 0);

                // Minus Buttons
                AddButton(220, 175, 0x38, 0x37, 49, GumpButtonType.Reply, 0);
                AddButton(220, 200, 0x38, 0x37, 50, GumpButtonType.Reply, 0);
                AddButton(220, 225, 0x38, 0x37, 51, GumpButtonType.Reply, 0);
            }
            else
            {
                AddLabel(60, 175, 38, @"-Locked-");
                AddLabel(60, 200, 38, @"-Locked-");
                AddLabel(60, 225, 38, @"-Locked-");

                AddLabel(330, 175, 38, @"???");
                AddLabel(330, 200, 38, @"???");
                AddLabel(330, 225, 38, @"???");
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            BaseCreature bc = (BaseCreature)m_Pet;

            if (from == null)
                return;
            #region Button Switch
            switch (info.ButtonID)
            {
                #region Hits / Stamina / Mana
                #region HitPoints Max
                // Max Buttons for hits/stam/mana
                case 1:
                    {
                        if (bc.HitsMax >= FSATS.NormalHITS)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalHITS - bc.HitsMax;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.Hits, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Stamina Max
                case 2:
                    {
                        if (bc.StamMax >= FSATS.NormalSTAM)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalSTAM - bc.StamMax;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                // Add to total
                                totalToAdd++;
                                // Remove from our count
                                addUntilCap--;
                            }
                            // Adjust the pets stats
                            if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Stam, totalToAdd, true);
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Mana Max
                case 3:
                    {
                        if (bc.ManaMax >= FSATS.NormalMANA)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalMANA - bc.ManaMax;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                // Remove from our count
                                addUntilCap--;
                            }
                            // Adjust the pets stats
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.Mana, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                // Hits/Stam/Mana +1 buttons
                #region Hits + 1
                case 4:
                    {
                        if (bc.HitsMax >= FSATS.NormalHITS)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.Hits, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Stamina + 1
                case 5:
                    {
                        if (bc.StamMax >= FSATS.NormalSTAM)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.Stam, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Mana + 1
                case 6:
                    {
                        if (bc.ManaMax >= FSATS.NormalMANA)
                            from.SendMessage("This cannot gain any farther.");
                        else if (bc.AbilityPoints != 0)
                        {
                                // Add 1 Point
                            AdjustStat(bc, PetStat.Mana, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                // Minus buttons for Hits/Stam/Mana
                #region Hits - 1
                case 7:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Hits, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Stamina - 1
                case 8:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Stam, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc,usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Mana -1
                case 9:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Mana, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #endregion
                #region Resistances
                #region Physical Resistance Max
                // Max buttons for resists
                case 10:
                    if (bc.PhysicalResistanceSeed >= FSATS.NormalPhys)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Get how much we can add until cap
                        int addUntilCap = FSATS.NormalPhys - bc.PhysicalResistanceSeed;
                        int totalToAdd = 0;

                        // Add all we can
                        while (addUntilCap != 0)
                        {
                            if (bc.AbilityPoints == 0)
                                break;
                            totalToAdd++;
                            addUntilCap--;
                        }
                        // Add the points
                        if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Phys, totalToAdd, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Fire Resistance Max
                case 11:
                    if (bc.FireResistSeed >= FSATS.NormalFire)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Get how much we can add until cap
                        int addUntilCap = FSATS.NormalFire - bc.FireResistSeed;
                        int totalToAdd = 0;

                        // Add all we can
                        while (addUntilCap != 0)
                        {
                            if (bc.AbilityPoints == 0)
                                break;
                            totalToAdd++;
                            addUntilCap--;
                        }
                        // Add the points
                        if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Fire, totalToAdd, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Cold Resistance Max
                case 12:
                    if (bc.ColdResistSeed >= FSATS.NormalCold)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Get how much we can add until cap
                        int addUntilCap = FSATS.NormalCold - bc.ColdResistSeed;
                        int totalToAdd = 0;

                        // Add all we can
                        while (addUntilCap != 0)
                        {
                            if (bc.AbilityPoints == 0)
                                break;
                            totalToAdd++;
                            addUntilCap--;
                        }
                        // Add the points
                        if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Cold, totalToAdd, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Energy Resistance Max
                case 13:
                    if (bc.EnergyResistSeed >= FSATS.NormalEnergy)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Get how much we can add until cap
                        int addUntilCap = FSATS.NormalEnergy - bc.EnergyResistSeed;
                        int totalToAdd = 0;

                        // Add all we can
                        while (addUntilCap != 0)
                        {
                            if (bc.AbilityPoints == 0)
                                break;
                            totalToAdd++;
                            addUntilCap--;
                        }
                        // Add the points
                        if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Energy, totalToAdd, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Poison Resistance Max
                case 14:
                    if (bc.PoisonResistSeed >= FSATS.NormalPoison)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Get how much we can add until cap
                        int addUntilCap = FSATS.NormalPoison - bc.PoisonResistSeed;
                        int totalToAdd = 0;

                        // Add all we can
                        while (addUntilCap != 0)
                        {
                            if (bc.AbilityPoints == 0)
                                break;
                            totalToAdd++;
                            addUntilCap--;
                        }
                        // Add the points
                        if (totalToAdd > 0)
                            AdjustStat(bc, PetStat.Poison, totalToAdd, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                //TODO: +1 boxes and - 1 boxes
                #region Physical Resistance + 1
                case 15:
                    if (bc.PhysicalResistanceSeed >= FSATS.NormalPhys)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Add 1 Point
                        AdjustStat(bc, PetStat.Phys, 1, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Fire Resistance + 1
                case 16:
                    if (bc.FireResistSeed >= FSATS.NormalFire)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Add 1 Point
                        AdjustStat(bc, PetStat.Fire, 1, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Cold Resistance + 1
                case 17:
                    if (bc.ColdResistSeed >= FSATS.NormalCold)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Add 1 Point
                        AdjustStat(bc, PetStat.Cold, 1, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Energy Resistance + 1
                case 18:
                    if (bc.EnergyResistSeed >= FSATS.NormalEnergy)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Add 1 Point
                        AdjustStat(bc, PetStat.Energy, 1, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Poison Resistance + 1
                case 19:
                    if (bc.PoisonResistSeed >= FSATS.NormalPoison)
                    {
                        // Its maxxed out, dont send a message, just reopen the gump
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    else if (bc.AbilityPoints != 0)
                    {
                        // Add 1 Point
                        AdjustStat(bc, PetStat.Poison, 1, true);

                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                // Minus
                #region Physical Resistance - 1
                case 20:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Phys, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Fire Resistance - 1
                case 21:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Fire, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Cold Resistance - 1
                case 22:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Cold, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Energy Resistance - 1
                case 23:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Energy, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Poison Resistance - 1
                case 24:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Poison, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #endregion
                #region Damage
                // Max
                #region Damage Minimum Max
                case 25:
                    {
                        if (bc.DamageMin >= FSATS.NormalMinDam)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalMinDam - bc.DamageMin;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.MinDmg, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Damage Maximum Max
                case 26:
                    {
                        if (bc.DamageMax >= FSATS.NormalMaxDam)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalMaxDam - bc.DamageMax;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.MaxDmg, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                // Plus 1
                #region Damage Minimum + 1
                case 27:
                    {
                        if (bc.DamageMin >= FSATS.NormalMinDam)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.MinDmg, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Damage Maximum + 1
                case 28:
                    {
                        if (bc.DamageMax >= FSATS.NormalMaxDam)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.MaxDmg, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                // Minus 1
                #region Damage Minimum - 1
                case 29:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.MinDmg, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Damage Maximum -1
                case 30:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.MaxDmg, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #endregion
                #region Stats
                #region Virtual Armor
                    // Max
                case 31:
                    {
                        if (bc.VirtualArmor >= FSATS.NormalVArmor)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalVArmor - bc.VirtualArmor;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.V_Armor, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                    // + 1
                case 32:
                    {
                        if (bc.VirtualArmor >= FSATS.NormalVArmor)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.V_Armor, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                    // - 1
                case 33:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.V_Armor, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Str /Dex / Int Max
                #region Strength Max
                case 34:
                    {
                        if (bc.Str >= FSATS.NormalSTR)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalSTR - bc.Str;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.Str, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Dexterity Max
                case 35:
                    {
                        if (bc.Dex >= FSATS.NormalDEX)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalDEX - bc.Dex;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.Dex, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Intelligence Max
                case 36:
                    {
                        if (bc.Int >= FSATS.NormalINT)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.NormalINT - bc.Int;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.Int, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #endregion
                #region Str /Dex / Int + 1
                #region Strength + 1
                case 37:
                    {
                        if (bc.Str >= FSATS.NormalSTR)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.Str, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Dexterity + 1
                case 38:
                    {
                        if (bc.Dex >= FSATS.NormalDEX)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.Dex, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Intelligence + 1
                case 39:
                    {
                        if (bc.Int >= FSATS.NormalINT)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.Int, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #endregion
                #region Str / Dex / Int -1
                #region Strength - 1
                case 40:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Str, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Dexterity - 1
                case 41:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Dex, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Intelligence - 1
                case 42:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.Int, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #endregion
                #endregion
                #region Pet Special Attacks
                    // We are on page 2, want to return there when reopen gump
                #region Roar Poison Fire Pet Attacks Max
                #region Roar Pet Attack Max
                case 43:
                    {
                        if (bc.RoarAttack >= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                            {
                                PetLevelGump gump = new PetLevelGump(bc, usedAbilityPointsThisSesion);
                                
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                            }
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.PetAttackSkillCap - bc.RoarAttack;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.RoarAttack, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Poison Pet Attack Max
                case 44:
                    {
                        if (bc.PetPoisonAttack>= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.PetAttackSkillCap - bc.PetPoisonAttack;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.PetPoisonAttack, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Fire Pet Attack Max
                case 45:
                    {
                        if (bc.FireBreathAttack >= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Get how much we can add until cap
                            int addUntilCap = FSATS.PetAttackSkillCap - bc.FireBreathAttack;
                            int totalToAdd = 0;

                            // Add all we can
                            while (addUntilCap != 0)
                            {
                                if (bc.AbilityPoints == 0)
                                    break;
                                totalToAdd++;
                                addUntilCap--;
                            }
                            // Add the points
                            if (totalToAdd > 0)
                                AdjustStat(bc, PetStat.FireBreathAttack, totalToAdd, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #endregion
                #region Roar Poison Fire Pet Attacks + 1
                #region Roar Attack + 1
                case 46:
                    {
                        if (bc.RoarAttack >= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.RoarAttack, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Poison Attack + 1
                case 47:
                    {
                        if (bc.PetPoisonAttack >= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.PetPoisonAttack, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #region Fire Attack + 1
                case 48:
                    {
                        if (bc.FireBreathAttack >= FSATS.PetAttackSkillCap)
                        {
                            // Its maxxed out, dont send a message, just reopen the gump
                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                        else if (bc.AbilityPoints != 0)
                        {
                            // Add 1 Point
                            AdjustStat(bc, PetStat.FireBreathAttack, 1, true);

                            // Open the gump again if we have more points
                            if (bc.AbilityPoints != 0)
                                from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                        }
                    }
                    break;
                #endregion
                #endregion
                #region Roar Poison Fire Pet Attacks  - 1
                #region Fire Attack - 1
                case 49:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.RoarAttack, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Poison Attack -1
                case 50:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.PetPoisonAttack, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #region Fire Attack -1
                case 51:
                    {
                        if (usedAbilityPointsThisSesion == 0)
                            from.SendMessage("Not enough points spent this session.");
                        else
                        {
                            // Remove the point
                            AdjustStat(bc, PetStat.FireBreathAttack, 1, false);
                        }
                        // Open the gump again if we have more points
                        if (bc.AbilityPoints != 0)
                            from.SendGump(new PetLevelGump(bc, usedAbilityPointsThisSesion));
                    }
                    break;
                #endregion
                #endregion
                #endregion
            }
            #endregion
        }
        #region Adjust Pet Stat
        /// <summary>
        /// Adjusts a pets skill or stat
        /// </summary>
        /// <param name="pet">The pet to adjust stats on</param>
        /// <param name="stat">The pet stat type</param>
        /// <param name="amount">The amount to adjust the stat/skill by</param>
        /// <param name="raiseOrLower">True for raise, false for lower</param>
        private void AdjustStat(BaseCreature pet, PetStat stat, int amount, bool raiseOrLower)
        {
            // If we were called with null references,or we have no ability points then abort.
            if (pet == null || amount == 0 || pet.AbilityPoints == 0) 
                return;

            switch (stat)
            {
                #region Cold Resist
                case PetStat.Cold:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.ColdResistSeed = pet.ColdResistSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.ColdResistSeed = pet.ColdResistSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Dexterity
                case PetStat.Dex:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.Dex = pet.Dex + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.Dex = pet.Dex - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Energy Resist
                case PetStat.Energy:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.EnergyResistSeed = pet.EnergyResistSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.EnergyResistSeed = pet.EnergyResistSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Fire Resist
                case PetStat.Fire:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.FireResistSeed = pet.FireResistSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.FireResistSeed = pet.FireResistSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Fire Breath
                case PetStat.FireBreathAttack:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.FireBreathAttack = pet.FireBreathAttack + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.FireBreathAttack = pet.FireBreathAttack - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Hit Points
                case PetStat.Hits:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.HitsMaxSeed = pet.HitsMaxSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.HitsMaxSeed = pet.HitsMaxSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Intelligence
                case PetStat.Int:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.Int = pet.Int + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.Int = pet.Int - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Mana
                case PetStat.Mana:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.ManaMaxSeed = pet.ManaMaxSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.ManaMaxSeed = pet.ManaMaxSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Max Damage
                case PetStat.MaxDmg:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.DamageMax = pet.DamageMax + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.DamageMax = pet.DamageMax - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Minimum Damage
                case PetStat.MinDmg:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.DamageMin = pet.DamageMin + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.DamageMin = pet.DamageMin - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Poison Attack
                case PetStat.PetPoisonAttack:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.PetPoisonAttack = pet.PetPoisonAttack + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.PetPoisonAttack = pet.PetPoisonAttack - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Physical Resistance
                case PetStat.Phys:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.PhysicalResistanceSeed = pet.PhysicalResistanceSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.PhysicalResistanceSeed = pet.PhysicalResistanceSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Poison Resistance
                case PetStat.Poison:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.PoisonResistSeed = pet.PoisonResistSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.PoisonResistSeed = pet.PoisonResistSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Roar Attack
                case PetStat.RoarAttack:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.RoarAttack = pet.RoarAttack + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.RoarAttack = pet.RoarAttack - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Stamina
                case PetStat.Stam:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.StamMaxSeed = pet.StamMaxSeed + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.StamMaxSeed = pet.StamMaxSeed - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Strength
                case PetStat.Str:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.Str = pet.Str + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.Str = pet.Str - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
                #region Virtual Armor
                case PetStat.V_Armor:
                    {
                        if (raiseOrLower)
                        {
                            pet.AbilityPoints = pet.AbilityPoints - amount;
                            pet.VirtualArmor = pet.VirtualArmor + amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion + amount;
                        }
                        else
                        {
                            pet.AbilityPoints = pet.AbilityPoints + amount;
                            pet.VirtualArmor = pet.VirtualArmor - amount;
                            usedAbilityPointsThisSesion = usedAbilityPointsThisSesion - amount;
                        }
                    }
                    break;
                #endregion
            }
        }
        #endregion
    }
}
